﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.SoldierArchives.Model;
using Yipusoft.SoldierArchives.BLL;

public partial class Police_TranslateDocument_TransferTreatList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            init();

        }
    }


    #region 通用代码
    protected void ListPageContral1_PageSizeChange(int pageSize, int PageIndex)
    {
        Bind(PageIndex);
    }

    void init()
    {
        if (Request.QueryString["where"] != null)
        {


        }
        else
        {
            lblwhere.Text = "";
        }
        ListPageContral1.SetFirstPage();
        Bind(0);
    }

    void Bind(int pageIndex)
    {
        int count = TransferTreat.GetCount(lblwhere.Text);
        ListPageContral1.ItemCount = count;
        GV.DataSource = TransferTreat.GetList(ListPageContral1.PageSize, pageIndex, lblwhere.Text);
        GV.DataBind();
    }

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblID = e.Row.FindControl("lblID") as Label;
            lblID.Text = Convert.ToString(GV.PageSize * ListPageContral1.CurrentPageIndex + (e.Row.RowIndex + 1));
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }
    }

    #endregion 通用代码

    protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Del")
        {
            Guid id = new Guid(e.CommandArgument.ToString());
            if (TransferTreat.Delete(id))
            {
                init();
                Prompt.Text = "提示：删除一条记录!";
            }
            else
            {
                Prompt.Text = "提示：对不起删除失败!";
            }
        }
    }

}
